package com.ld.security.auth.server.base.auth.impl;

import com.ld.security.auth.common.base.constants.JwtTokenConstant;
import com.ld.security.auth.common.base.entity.JwtUserInfo;
import com.ld.security.auth.server.base.auth.UserAuth;
import com.ld.security.auth.server.modules.ge.constant.GeModelConstant;
import com.ld.security.auth.server.modules.ge.po.GetAllModelDetailsPo;
import com.ld.security.auth.server.modules.ge.service.IGeModelService;
import com.ld.security.auth.server.modules.sys.entity.SysToken;
import com.ld.security.auth.server.modules.sys.entity.SysUser;
import com.ld.security.auth.server.modules.sys.service.*;
import com.ld.security.common.core.exception.ApiException;
import com.ld.security.common.core.util.JsonUtil;
import com.ld.security.common.core.util.ReflectionUtil;
import com.ld.security.common.mybatis.base.service.ProxyService;
import com.ld.security.common.shiro.constants.ShiroCacheConstants;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component

class UserAuthImpl implements UserAuth {



    @Autowired
    private ISysUserService iSysUserService;



    @Autowired
    ProxyService proxyService;


    @Override
    public SysUser findByUsername(String username) {
        SysUser sysUser = iSysUserService.findByUsername(username);
        return sysUser;
    }


    @Autowired
    private IGeModelService iGeModelService;

    @Override

    public JwtUserInfo getUserInfo(      String username) {
        JwtUserInfo info =  new JwtUserInfo();
        SysUser sysUser =  this.findByUsername(username);
        if(sysUser == null){
            ApiException.throw400("用户异常");
        }
        GetAllModelDetailsPo po = new GetAllModelDetailsPo();
        po.setTableType(GeModelConstant.tableType.anon);
        info.setUser(sysUser);
        proxyService.initMapping(info.getClass(), Arrays.asList(info));





        return info;
    }



}
